#include "mesh/MeshUtil.h"

MeshUtil::MeshUtil() {}

std::pair<Face*, Face*> MeshUtil::triangulateQuad(Face *face) {
	Face *face1 = new Face;
	Face *face2 = new Face;

	if (face->vertices.size() == 4) {
		face1->vertices.push_back(face->vertices[0]);
		face1->vertices.push_back(face->vertices[1]);
		face1->vertices.push_back(face->vertices[3]);

		face2->vertices.push_back(face->vertices[1]);
		face2->vertices.push_back(face->vertices[2]);
		face2->vertices.push_back(face->vertices[3]);
	}

	if (face->vertexNormals.size() == 4) {
		face1->vertexNormals.push_back(face->vertexNormals[0]);
		face1->vertexNormals.push_back(face->vertexNormals[1]);
		face1->vertexNormals.push_back(face->vertexNormals[3]);

		face2->vertexNormals.push_back(face->vertexNormals[1]);
		face2->vertexNormals.push_back(face->vertexNormals[2]);
		face2->vertexNormals.push_back(face->vertexNormals[3]);
	}

	face1->material = face->material;
	face2->material = face->material;

	std::pair<Face*, Face*> pair(face1, face2);

	return pair;
}

MeshUtil::~MeshUtil() {}
